Ruby Exercide - Lecture 2
  • Write the 2 Ruby programs described below.
  • Hand in just the Ruby code, not results or anything.
  • I will run your program.
  • Comment your code in your own words using # comments.
  • My grade will be based on code itself and on output correctness.
  • Due Date: Feb 05, 2010 (but I don't recommend waiting, there will be exercises for other labs in just this course)

 
Exercise 1 - Upload an altered data file to Genboree using Ruby and the Genboree API
  • Download this LFF file
  • Write a Ruby program that does two things:
    1. Changes the 'type' of each record to be your BCM login name. So the track name will end up as something like 'andrewj:RefSeq' (except with your login, not mine).
    2. After modifying all the records, uploads to a NEW Hg18-based database (you can create one in the Genboree UI) the modified LFF records using the Genboree API.
  • Recall that the API takes LFF text.
  • Tell me, in your email, the name of the database containing the uploaded track.

 
Exercise 2 - Retrieve some project information from Genboree using the API
  • Write a Ruby program that retrieves certain details of the 'CAD_Course_2009' project within the course Genboree group ('Course 311-405: CAD 2009')
  • Have your Ruby program retrieve and print out:
    • The project resource itself (the raw response text).
    • The project description, in all-uppercase. [extract the project description from the parsed result and print JUST that description]
    • The project title, in lower case. [extract it from the parsed result and print JUST that title]
  • There's a little more thinking (but only a tiny bit) in this exercise, and referring to the API help docs will go a long way.
  • Use your knowledge of Ruby Hashes to extract out the exact title and description text for display.
  • Note that you will likely need to install some gems, especially the ones I used when doing this same thing. For example, the 'json' (or 'json_pure' for Windows) gem, the 'rest-open-uri' gem, etc..
  • (Yes, I know the group and project name both still say '2009' in them. No idea why, since it's easy in Genboree for the organizers to have fixed that.)